SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.vw_usuariocuise
AS
SELECT     dbo.tb_Organizaciones.CUISE
FROM         dbo.tb_Reparticiones INNER JOIN
                      dbo.tb_Organizaciones ON dbo.tb_Organizaciones.idOrganizaciones = dbo.tb_Reparticiones.Organizacion
WHERE     (dbo.tb_Reparticiones.idReparticion =
                          (SELECT     idreparticion
                            FROM          tb_usuarios
                            WHERE      ntuser = SYSTEM_USER))
GO
GRANT SELECT ON  [dbo].[vw_UsuarioCUISE] TO [public]
GRANT SELECT ON  [dbo].[vw_UsuarioCUISE] TO [SoloVer]
GO
